package cc.aliza.lib.mongo.core.decoder;

import cc.aliza.lib.mongo.core.utils.FieldUtil;
import cc.aliza.lib.mongo.core.utils.Operator;
import org.bson.Document;

import java.lang.reflect.Field;

/**
 * 『给时光以生命·给岁月以文明』
 *
 * @author Zhang Jing (byrdkm17@gmail.com).
 */
public class IdDecoder extends AbstractDecoder {

    public IdDecoder(Document document, Field field) {
        super(field);
        value = document.get(Operator.ID);
    }

    @Override
    public void decode(Object obj) {
        FieldUtil.set(obj, field, value.toString());
    }
}
